package service;

import bean.model.marketUser.MarketUser;
import bean.model.marketUser.MarketUserExample;
import mapper.MarketUserMapper;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class AuthServiceImpl implements AuthService{
    @Override
    public List<MarketUser> getMarketUser(String userName, String password) {
        //这个地方要获取数据库数据，然后把数据返回
        List<MarketUser> marketUserList=null;
        MarketUserExample example=new MarketUserExample();
        //创建一个criteria
        MarketUserExample.Criteria criteria= example.createCriteria();

        criteria.andUsernameEqualTo(userName);
        criteria.andPasswordEqualTo(password);

        //这里面少一个mapper，我们有mapper吗？有的
        SqlSession sqlSession=CskaoyanSqlSessionFactory.sqlSessionFactory.openSession();
        MarketUserMapper marketUserMapper=sqlSession.getMapper(MarketUserMapper.class);
        marketUserList=marketUserMapper.selectByExample(example);

        return marketUserList;
    }
}
